package com.info33.platform.doc.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.info33.platform.common.mvc.controller.BaseController;
import com.info33.platform.common.mvc.vo.Result;
import com.info33.platform.doc.dto.DocFileUserSaveDTO;
import com.info33.platform.doc.entity.DocFileUser;
import com.info33.platform.doc.service.DocFileUserService;
import com.info33.platform.doc.vo.DocFileUserVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author admin
 */
@RestController
@RequestMapping("/DocFileUser")
@Api(tags = "文档管理 - 文件用户")
public class DocFileUserController extends BaseController<DocFileUserService, DocFileUser> {

    private final DocFileUserService docFileUserService;

    @Autowired
    public DocFileUserController(DocFileUserService docFileUserService) {
        super(docFileUserService);
        this.docFileUserService = docFileUserService;
    }
    
    @PostMapping("/saveFileUser")
    @ApiOperation(value = "保存文件权限")
    public Result<?> saveFileUser(@RequestBody DocFileUserSaveDTO docFileUserSaveDTO) {
        return docFileUserService.saveFileUser(docFileUserSaveDTO);
    }
    
    @GetMapping(value = "/getFileUserDetail/{fileId}")
	@ApiOperation(value = "获取文档对应权限")
	public Result<Map<Integer,List<DocFileUserVO>>> getFileUserDetail(@PathVariable Long fileId) {
        return docFileUserService.getFileUserDetail(fileId);
	}

}